home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / src / fig03_04.jar / Ch03 / Fig03_04 / Fig03_04.cpp
C/C++ Source or Header  |  1997-10-11  |  664b  |  37 lines

  1. // Fig. 3.4: fig03_04.cpp
  2. // Finding the maximum of three integers
  3. #include <iostream.h>
  4.  
  5. int maximum( int, int, int );   // function prototype
  6.  
  7. int main()
  8. {
  9.    int a, b, c;
  10.  
  11.    cout << "Enter three integers: ";
  12.    cin >> a >> b >> c;
  13.  
  14.    // a, b and c below are arguments to 
  15.    // the maximum function call
  16.    cout << "Maximum is: " << maximum( a, b, c ) << endl;
  17.  
  18.    return 0;
  19. }
  20.  
  21. // Function maximum definition
  22. // x, y and z below are parameters to 
  23. // the maximum function definition
  24. int maximum( int x, int y, int z )
  25. {
  26.    int max = x;
  27.  
  28.    if ( y > max )
  29.       max = y;
  30.  
  31.    if ( z > max )
  32.       max = z;
  33.  
  34.    return max;
  35. }
  36.  
  37.